package cn.edu.nyist.service.impl;

import cn.edu.nyist.entity.Admin;
import cn.edu.nyist.entity.CommonUser;
import cn.edu.nyist.mapper.CommonUserMapper;
import cn.edu.nyist.service.CommonUserService;
import cn.edu.nyist.util.PageBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * (CommonUser)表服务实现类
 *
 * @author makejava
 * @since 2021-03-21 17:38:25
 */
@Service("commonUserService")
public class CommonUserServiceImpl implements CommonUserService {
    @Autowired
    private CommonUserMapper commonUserMapper;

    @Override
    public CommonUser login(String username, String password) {
        return commonUserMapper.login(username,password);
    }

    @Override
    public PageBean<CommonUser> queryPage(Map<String, Object> paramMap) {
        PageBean<CommonUser> pageBean = new PageBean<>((Integer) paramMap.get("pageno"),(Integer) paramMap.get("pagesize"));

        Integer startIndex = pageBean.getStartIndex();
        paramMap.put("startIndex",startIndex);
        List<CommonUser> datas = commonUserMapper.queryList(paramMap);
        pageBean.setDatas(datas);

        Integer totalsize = commonUserMapper.queryCount(paramMap);
        pageBean.setTotalsize(totalsize);
        return pageBean;
    }

    @Override
    public int insertCommonUser(CommonUser user) {
        return commonUserMapper.insertCommonUser(user);
    }

    @Override
    public CommonUser selectById(Integer id) {
        return commonUserMapper.selectById(id);
    }

    @Override
    public int delByCommonUserIds(List<Integer> ids) {
        return commonUserMapper.delByCommonUserIds(ids);
    }

    @Override
    public int editByCommonUser(CommonUser user) {
        return commonUserMapper.editByCommonUser(user);
    }

    @Override
    public CommonUser selectByName(String username) {
        return commonUserMapper.selectByName(username);
    }

    @Override
    public CommonUser selectByEmail(String email) {
        return commonUserMapper.selectByEmail(email);
    }

    @Override
    public CommonUser selectByPhone(String phone) {
        return commonUserMapper.selectByEmail(phone);
    }

    @Override
    public CommonUser selectBySex(String sex) {
        return commonUserMapper.selectBySex(sex);
    }
}